<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Yaf_Application的构造函数</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="yaf-application.clone.html">Yaf_Application::__clone</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="yaf-application.destruct.html">Yaf_Application::__destruct</a></div>
 <div class="up"><a href="class.yaf-application.html">Yaf_Application</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="yaf-application.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Yaf_Application::__construct</h1>
  <p class="verinfo">(Yaf &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">Yaf_Application::__construct</span> &mdash; <span class="dc-title">Yaf_Application的构造函数</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yaf-application.construct-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span><span class="methodname"><strong>Yaf_Application::__construct</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$config</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$envrion</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   初始化一个 <a href="class.yaf-application.html" class="classname">Yaf_Application</a>.
  </p>



 </div>


 <div class="refsect1 parameters" id="refsect1-yaf-application.construct-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<em><code class="parameter">config</code></em></dt>

    <dd>

     <p class="para">
       关联数组的配置, 或者一个指向ini格式的配置文件的路径的字符串。
     </p>
     <p class="para">
       如果是一个ini配置文件，那配置文件中应该有一个定义了<a href="yaf.configuration.html#ini.yaf.environ" class="link">yaf.environ</a>
       的配置节。这个在生产环境中是默认的。
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        如果你使用了ini配置文件作为你应用配置的容器，你需要打开<a href="yaf.configuration.html#ini.yaf.cache-config" class="link">yaf.cache_config</a>
        来提升性能。
       </p>
      </p></blockquote>
     </p>
     <p class="para">
       And the config entry(and there default value) list blow:
      <div class="example" id="example-4020">
       <p><strong>Example #1 A ini config file example</strong></p>
       <div class="example-contents">
<div class="inicode"><pre class="inicode">[product]
;this one should alway be defined, and have no default value
application.directory=APPLICATION_PATH

;following configs have default value, you may no need to define them
application.library = APPLICATION_PATH . &quot;/library&quot;
application.dispatcher.throwException=1
application.dispatcher.catchException=1

application.baseUri=&quot;&quot;

;the php script ext name
ap.ext=php

;the view template ext name
ap.view.ext=phtml

ap.dispatcher.defaultModuel=Index
ap.dispatcher.defaultController=Index
ap.dispatcher.defaultAction=index

;defined modules
ap.modules=Index</pre>
</div>
       </div>

      </div>
     </p>
    </dd>

   
   
    <dt>
<em><code class="parameter">envrion</code></em></dt>

    <dd>

     <p class="para">
      Which section will be loaded as the final config
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-yaf-application.construct-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-yaf-application.construct-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-4021">
   <p><strong>Example #2 <span class="function"><strong>Yaf_Application::__construct()</strong></span>example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />defined</span><span style="color: #007700">(</span><span style="color: #DD0000">'APPLICATION_PATH'</span><span style="color: #007700">)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;APPLICATION_PATH&nbsp;will&nbsp;be&nbsp;used&nbsp;in&nbsp;the&nbsp;ini&nbsp;config&nbsp;file<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">||&nbsp;</span><span style="color: #0000BB">define</span><span style="color: #007700">(</span><span style="color: #DD0000">'APPLICATION_PATH'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">__DIR__</span><span style="color: #007700">));&nbsp;</span><span style="color: #FF8000">//__DIR__&nbsp;was&nbsp;introduced&nbsp;after&nbsp;PHP&nbsp;5.3<br /><br /></span><span style="color: #0000BB">$application&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Yaf_Application</span><span style="color: #007700">(</span><span style="color: #0000BB">APPLICATION_PATH</span><span style="color: #007700">.</span><span style="color: #DD0000">'/conf/application.ini'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$application</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">bootstrap</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">run</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
</pre></div>
   </div>
  </div>
  <div class="example" id="example-4022">
   <p><strong>Example #3 <span class="function"><strong>Yaf_Application::__construct()</strong></span>example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$config&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"application"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"directory"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">realpath</span><span style="color: #007700">(</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">))&nbsp;.&nbsp;</span><span style="color: #DD0000">"/application"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;),<br />);<br /><br /></span><span style="color: #FF8000">/**&nbsp;Yaf_Application&nbsp;*/<br /></span><span style="color: #0000BB">$application&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Yaf_Application</span><span style="color: #007700">(</span><span style="color: #0000BB">$config</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$application</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">bootstrap</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">run</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-yaf-application.construct-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><a href="class.yaf-config-ini.html" class="classname">Yaf_Config_Ini</a></li>
  </ul>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="yaf-application.clone.html">Yaf_Application::__clone</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="yaf-application.destruct.html">Yaf_Application::__destruct</a></div>
 <div class="up"><a href="class.yaf-application.html">Yaf_Application</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
